//
//  PywValidProblemView.m
//  PywSdk
//
//  Created by smallwave on 16/8/19.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "PywValidProblemHeaderView.h"
#import "PywMasonry.h"

@interface PywValidProblemHeaderView ()
@property (nonatomic, strong) UIButton *cutBtn;
@end

@implementation PywValidProblemHeaderView
- (instancetype)initWithFrame:(CGRect)frame
                     Delegate:(id<PywValidProblemViewDelegate>)delegate{
    self = [super initWithFrame:frame];
    if (self) {
        self.delegate = delegate;
        [self addSubview:self.cutBtn];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    __weak typeof(self) wSelf = self;
    [self.cutBtn mas_makeConstraints:^(PywMASConstraintMaker *make) {
        make.bottom.right.equalTo(wSelf);
        make.width.equalTo(@100);
        make.height.equalTo(@44);
    }];
}
- (void)changeProblemAction:(UIButton *)cutBtn{
    if ([self.delegate respondsToSelector:@selector(validProblemView:didSelectedCutButton:)]) {
        [self.delegate validProblemView:self didSelectedCutButton:cutBtn];
    }
}
- (UIButton *)cutBtn{
    if (!_cutBtn) {
        _cutBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cutBtn.backgroundColor = [UIColor clearColor];
        _cutBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_cutBtn setTitleColor:UIColorFromRGB(0x007EFF) forState:UIControlStateNormal];
        [_cutBtn setTitle:@"换个问题" forState:UIControlStateNormal];
        
        [_cutBtn addTarget:self action:@selector(changeProblemAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cutBtn;
}

@end
